//
//  L2Tab2.m
//  Lesson2
//
//  Created by Alexander Trifonov on 20.04.12.
//  Copyright (c) 2012 fgengine@gmail.com. All rights reserved.
//

#import "L2Tab2.h"

@implementation L2Tab2

- (IBAction)onTest:(id)sender
{
    BOOL valid = NO;
    if([email.text length] >= 6)
    {
        NSRange s = [email.text rangeOfString:@"@"];
        if(s.location != NSNotFound)
        {
            NSRange t = [email.text rangeOfString:@"."];
            if(t.location != NSNotFound)
            {
                if(s.location < t.location)
                {
                    valid = [email.text hasSuffix:@".com"];
                }
            }
        }
    }
    result.text = (valid == YES) ? @"YES" : @"NO";
}

- (void)dealloc {
    [email release];
    [result release];
    [test release];
    [super dealloc];
}

- (void)viewDidUnload {
    [email release];
    email = nil;
    [result release];
    result = nil;
    [test release];
    test = nil;
    [super viewDidUnload];
}
@end
